package com.ruoyi.web.controller.system;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.PmResources;
import com.ruoyi.system.service.IPmResourcesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * 存储资源信息的Controller
 *
 * @author ruoyi
 * @date 2024-04-21
 */
@RestController
@RequestMapping("/system/resources")
public class PmResourcesController extends BaseController {
    @Autowired
    private IPmResourcesService pmResourcesService;
    @Value("${ruoyi.profile}")
    private String profile;

    /**
     * 查询存储资源信息的列表
     */
    @PreAuthorize("@ss.hasPermi('system:resources:list')")
    @GetMapping("/list")
    public TableDataInfo list(PmResources pmResources) {
        startPage();
        List<PmResources> list = pmResourcesService.selectPmResourcesList(pmResources);
        return getDataTable(list);
    }

    /**
     * 导出存储资源信息的列表
     */
    @PreAuthorize("@ss.hasPermi('system:resources:export')")
    @Log(title = "存储资源信息的", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PmResources pmResources) {
        List<PmResources> list = pmResourcesService.selectPmResourcesList(pmResources);
        ExcelUtil<PmResources> util = new ExcelUtil<PmResources>(PmResources.class);
        util.exportExcel(response, list, "存储资源信息的数据");
    }

    /**
     * 获取存储资源信息的详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:resources:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(pmResourcesService.selectPmResourcesById(id));
    }

    /**
     * 新增存储资源信息的
     */
    @PreAuthorize("@ss.hasPermi('system:resources:add')")
    @Log(title = "存储资源信息的", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PmResources pmResources) {
        return toAjax(pmResourcesService.insertPmResources(pmResources));
    }

    /**
     * 修改存储资源信息的
     */
    @PreAuthorize("@ss.hasPermi('system:resources:edit')")
    @Log(title = "存储资源信息的", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PmResources pmResources) {
        return toAjax(pmResourcesService.updatePmResources(pmResources));
    }

    /**
     * 删除存储资源信息的
     */
    @PreAuthorize("@ss.hasPermi('system:resources:remove')")
    @Log(title = "存储资源信息的", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(pmResourcesService.deletePmResourcesByIds(ids));
    }

}
